var projectAdd = {
	check : function() {
		var f_id = $("#fcCategoryId").attr("fcCategoryId");
		var name = $("#projectName").val();
		var impl = $("#implTime").val();
		var fund = $("#fund").val();
		var mgrDepart = $("#mgrDepart").val();

		var fundPlan = $("#fundPlan").val();
		if (checkSC(fundPlan)) {
			errorAlert("资金计划不能含有特殊字符！<br>如<br>英文模式的： ! $ ( ) : ; ? ' \" <br>中英文模式的： / \\ + = @ # & *");
			return false;
		}

		if (!checkValue3(f_id)) {
			errorAlert("请选择一级类别！");
			return false;
		} else if (!checkValue(name)) {
			errorAlert("请填写项目名称！");
			return false;
		} else if (!checkValue(impl)) {
			errorAlert("请填写实施时间！");
			return false;
		} else if (!checkValue4(fund)) {
			errorAlert("请正确填写总投资！");
			return false;
		} else if (!checkValue(mgrDepart)) {
			errorAlert("请填写主管部门！");
			return false;
		} else {
			projectAdd.add(f_id, name, impl, fund, mgrDepart);
		}
	},
	add : function(f_id, name, impl, fund, mgrDepart) {// fundPlan plan area
		art.dialog({
			id : "addProjectLoading",
			title : "录入中",
			content : "<img src='/controls/artDialog/skins/icons/loading.gif'>"
					+ "<font color='blue'><strong>录入中，请稍后！</strong></font>",
			lock : true
		});
		var s_id = $("#scCategoryId").attr("scCategoryId");
		var t_id = $("#tcCategoryId").attr("tcCategoryId");

		var fundPlan = $("#fundPlan").val();
		var build = $("#buildSide").val();
		var plan = $("#plan").val();
		var area = $("#area").val();
		var description = $("#description").val();
		var remarks = $("#remarks").val();
		var sign = $("#sign").val();
		var uuid = $("#addUuid").val();
		$.ajax({
			data : {
				"f_id" : f_id,
				"mgrDepart" : mgrDepart,
				"projectName" : name,
				"fund" : fund,
				"implTime" : impl,
				"buildSide" : build,
				"s_id" : s_id,
				"t_id" : t_id,
				"fundPlan" : fundPlan,
				"plan" : plan,
				"area" : area,
				"remarks" : remarks,
				"description" : description,
				"uuid" : uuid,
				"sign" : sign
			},
			dataType : "json",
			type : "post",
			url : "/app/project!addProject",
			success : function(data) {
				art.dialog({
					id : "addProjectLoading"
				}).close();
				backUrl.addCookie(data.state);
				if (data.state == "success") {
					art.dialog({
						id : "successAdd",
						icon : 'succeed',
						lock : true,
						content : data.msg,
						button : [ {
							name : '确定',
							callback : function() {
								location.reload();
							},
							focus : true
						} ],
						cancelVal : '取消',
						cancel : true
					});
				} else if (data.state == "error") {
					errorAlert(data.msg);
				}
			}
		});
	}
};
function onloadProjectAdd() {
	$("#implTime").focus(function() {
		WdatePicker({
			dateFmt : 'yyyy-MM'
		});
	});

	$("#firstCategory").click(function() {
		var f_id = $("#fcCategoryId").attr("fcCategoryId");
		if (null != f_id && 1 != Number(f_id)) {
			var plan = $("#plan option:first").val();
			if (plan == "储备") {
				$("#plan option:first").remove();
			}
		} else {
			var plan = $("#plan option:first").val();
			if (plan != "储备") {
				$("#plan option:first").before("<option value='储备'>储备</option>");
				$("#plan").val("储备");
			}
		}
	});

	$(".btn").click(function() {
		projectAdd.check();
	});
};